package validator

import (
	"regexp"

	"github.com/go-playground/validator/v10"
)

// MobileValidator 自定义移动电话校验方法
func MobileValidator(fl validator.FieldLevel) bool {
	mobile := fl.Field().String()
	pattern := `^[1][3,4,5,7,8][0-9]{9}$`
	ok, err := regexp.MatchString(pattern, mobile)
	if err != nil || !ok {
		return false
	}
	return true
}
